<template>
    <div v-show="!item.componentProps.hidden">
        <a-upload v-model:file-list="item.componentProps.fileList" name="file" :action="item.componentProps.action"
            :headers="item.componentProps.headers" @change="handleFileChange" :beforeUpload="beforeUpload">
            <a-button :disabled="item.componentProps.disabled">
                <upload-outlined></upload-outlined>
                {{ item.label }}
            </a-button>
        </a-upload>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { getCustomMethod } from '../../pageManager.js'
const props = defineProps({
    item: {
        type: Object,
        required: true
    },
})

// 文件发生改变时
const handleFileChange = (info) => {
    // console.log("信息：",info)
    getCustomMethod(props.item, "change", info);
}

// TODO 上传前事件模块无法返回值的问题
const beforeUpload = (file) => {
    // console.log("文件：",file)
    return getCustomMethod(props.item, "beforeUpload", file);
}


</script>


<style scoped>
</style>